package com.macaku.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.macaku.component.AtomicEmailSender;
import com.macaku.domain.dto.ModelMessage;
import com.macaku.domain.po.Email;
import com.macaku.service.EmailService;
import com.macaku.mapper.EmailMapper;
import lombok.RequiredArgsConstructor;
import org.assertj.core.util.Preconditions;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
* @author 马拉圈
* @description 针对表【email】的数据库操作Service实现
* @createDate 2024-01-14 18:48:22
*/
@Service
@RequiredArgsConstructor
public class EmailServiceImpl extends ServiceImpl<EmailMapper, Email>
    implements EmailService{

    private final AtomicEmailSender atomicEmailSender;

    @Override
    public void sendSimpleMailMessage(Email email) {
        atomicEmailSender.sendSimpleMailMessage(email);
    }

    @Override
    public void sendMailWithFile(Email email, File file) {
        atomicEmailSender.sendMailWithFile(email, file);
    }

    @Override
    public void sendModelMail(Email email, ModelMessage modelMessage) {
        atomicEmailSender.sendModelMail(email, "ModelMessage.html", modelMessage);
    }

    @Override
    public String selectNameByEmail(String email) {
        return email;
    }

}




